package main.java.DMDE.model;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public abstract class EntityWithState extends Entity {

	private List<Attribute> attributes;
	private List<Modifier> modifiers;
	private Visibility visibility;

	public EntityWithState() {
	    	super();
		setAttributes(new ArrayList<Attribute>());
		setModifiers(new ArrayList<Modifier>());
		
	}
	
	public EntityWithState(String name, UUID id) {
		super(name, id);
		setAttributes(new ArrayList<Attribute>());
		setModifiers(new ArrayList<Modifier>());
	}

	public List<Attribute> getAttributes() {
		return attributes;
	}

	public void setAttributes(List<Attribute> attributes) {
		this.attributes = attributes;
	}

	private boolean containsAttribute(Attribute attribute) {
		for (Attribute attrib : attributes) {
			if (attrib.is(attribute))
				return true;
		}
		return false;
	}

	private boolean containsModifier(Modifier modifier) {
		for (Modifier mod : modifiers) {
			if (mod.is(modifier))
				return true;
		}
		return false;
	}

	public void addAttribute(Attribute attribute) {
		if (!containsAttribute(attribute))
			attributes.add(attribute);
	}

	public List<Modifier> getModifiers() {
		return modifiers;
	}

	public void setModifiers(List<Modifier> modifiers) {
		this.modifiers = modifiers;
	}

	public void addModifier(Modifier modifier) {
		if (!containsModifier(modifier))
			this.modifiers.add(modifier);
	}

	public Visibility getVisibility() {
		return visibility;
	}

	public void setVisibility(Visibility visibility) {
		this.visibility = visibility;
	}

}
